<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/web/ui/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/web/ui/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">企业全称</label>
        <div class="layui-input-block">

            <input type="hidden" name="id" id="id">

            <input type="text" id="name" name="name" lay-verify="required" lay-reqtext="企业名不能为空" placeholder="请输入企业全称" value="" class="layui-input">
            <tip>填写要修改后的企业的名称。</tip>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label required">主营项目</label>
        <div class="layui-input-block">
            <input type="text" id="business" name="business" class="layui-input" lay-verify="required" lay-reqtext="主营项目不能为空" placeholder="请输入主营项目">
            <tip>填写要修改后的主营项目。</tip>
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">联系人</label>
        <div class="layui-input-block">
            <input type="text" id="contact" name="contact" class="layui-input" lay-verify="required" lay-reqtext="联系人不可为空" placeholder="请输入联系人">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-block">
            <input type="text" id="tel" name="tel" class="layui-input" lay-verify="required" lay-reqtext="联系方式不可为空" placeholder="请输入联系方式">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input disabled type="text" id="loginName" name="loginName" class="layui-input" lay-verify="required" lay-reqtext="用户名不可为空" placeholder="请输入用户名">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">登录密码</label>
        <div class="layui-input-block">
            <input type="text" id="loginPwd" name="loginPwd" class="layui-input" lay-verify="required" lay-reqtext="登录密码不可为空" placeholder="请输入登录密码">
        </div>
    </div>

    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">申请入驻时间</label>
        <div class="layui-input-block">
            <input disabled type="text" id="createTime" name="createTime" class="layui-input" lay-verify="required" lay-reqtext="申请入驻时间不可为空" placeholder="请输入申请入驻时间">
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
</div>
<script src="/web/ui/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>

<script src="/web/js/axios.min.js"></script>

<script>

    const firm = JSON.parse(localStorage.getItem("t"));
    (function () {
        document.getElementById("id").value=firm.id;
        document.getElementById("name").value=firm.name;
        document.getElementById("business").value=firm.business;
        document.getElementById("contact").value=firm.contact;
        document.getElementById("tel").value=firm.tel;
        document.getElementById("loginName").value=firm.loginName;
        document.getElementById("loginPwd").value=firm.loginPwd;
        document.getElementById("createTime").value=firm.createTime;
        localStorage.removeItem("t");
    })()

    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, async function () {

                await axios.post("/firm/common/update", {
                    id: data.field.id,
                    name: data.field.name,
                    business: data.field.business,
                    contact: data.field.contact,
                    tel: data.field.tel,
                    loginName: data.field.loginName,
                    loginPwd: data.field.loginPwd,
                    createTime: data.field.createTime,
                }).then(res=> {
                    if (res.data.code===0){
                        console.log(res.data);
                    }
                })

                // 关闭弹出层
                layer.close(index);

                // 刷新父页面
                window.parent.location.reload();
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>